package com.wwz.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wwz.entity.Role;
import com.wwz.mapper.RoleMapper;
import com.wwz.service.IRoleService;
import org.springframework.stereotype.Service;

@Service
public class IRoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Override
    public void addOrUpData(Role role) {
        Role one = getOne(Wrappers.<Role>query().lambda()
                .eq(Role::getId, role.getId()), false);

        if (one == null){
            role.setId(StrUtil.uuid());
            save(role);
            return;
        }
        updateById(role);
    }
}
